import ast,json
# -*- coding:utf-8  -*-
# @Time    : 2021/5/16 23:13
__author__ = 'wangd'


def get_only_values(k, dics, defaultList):
    if type(dics) is dict:
        keys = get_dic_keys(dics)
        for i in keys:
            if i == k:
                defaultList.append(dics[k])
            else:
                va = get_keys_values(i, dics)
                get_only_values(k, va,defaultList)
    elif type(dics) is str and "{" in dics:
        strToDict=ast.literal_eval(dics)
        keys = get_dic_keys(strToDict)
        for i in keys:
            if i == k:
                defaultList.append(strToDict[k])
            else:
                va = get_keys_values(i, strToDict)
                get_only_values(k, va,defaultList)
    elif type(dics) is list:
        for i in dics:
            get_only_values(k,i,defaultList)
    else:
        pass
    return defaultList

def get_keys_values(keys,dics):
    value=dics[keys]
    return value

def get_dic_keys(dics):
    keys=dics.keys()
    return keys